// 放置全局指令
import Vue from 'vue'
import store from '@/store'

const adminPerms = '*:*:*'

Vue.directive('permission', {
    //el:使用自定义指令的DOM元素
    //binding： 对象，binding.value可以接受到外部传递过来的值
    inserted(el, binding) {
        /* console.log(el)
        console.log(binding) */
        const perms = store.state.menu.permission
        if (perms.includes(adminPerms)) {
            return
        }
        if (!perms.includes(binding.value)) {
            el.remove()
        }
    }
})
